package org.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.entity.TestJob;
import org.example.mapper.TestJobMapper;
import org.example.service.TestJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * <p>
 * job表 服务实现类
 * </p>
 *
 * @author yangzhenyu
 * @since 2023-04-27 04:38:45
 */
@Service
public class TestJobServiceImpl extends ServiceImpl<TestJobMapper, TestJob> implements TestJobService {

    @Autowired
    TestJobMapper mapper;
    @Transactional
    @Override
    public Boolean add(int shardingItem) {
        TestJob build = TestJob.builder()
                .shardingItem(shardingItem)
                .createTime(new Date())
                .build();
        mapper.insert(build);
        return Boolean.TRUE;
    }

    @Override
    public int queryCount(int item) {
        return mapper.queryCount(item);
    }
}
